
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>docker15 初始dockerfile · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="docker16 数据卷容器.html" />
    
    
    <link rel="prev" href="docker14 具名挂载和匿名挂载.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="docker01 docker能干嘛.html">
            
                <a href="docker01 docker能干嘛.html">
            
                    
                    docker01 docker能干嘛
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="docker02 安装docker.html">
            
                <a href="docker02 安装docker.html">
            
                    
                    docker02 安装docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="docker03 docker原理.html">
            
                <a href="docker03 docker原理.html">
            
                    
                    docker03 docker原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="docker04 镜像基本命令.html">
            
                <a href="docker04 镜像基本命令.html">
            
                    
                    docker04 镜像基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="docker05 容器基本命令.html">
            
                <a href="docker05 容器基本命令.html">
            
                    
                    docker05 容器基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="docker06 常用其他命令.html">
            
                <a href="docker06 常用其他命令.html">
            
                    
                    docker06 常用其他命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="docker07 进入当前正在运行的容器.html">
            
                <a href="docker07 进入当前正在运行的容器.html">
            
                    
                    docker07 进入当前正在运行的容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="docker08 部署nginx.html">
            
                <a href="docker08 部署nginx.html">
            
                    
                    docker08 部署nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="docker09 部署tomcat.html">
            
                <a href="docker09 部署tomcat.html">
            
                    
                    docker09 部署tomcat
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="docker10 可视化面板.html">
            
                <a href="docker10 可视化面板.html">
            
                    
                    docker10 可视化面板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="docker11 镜像原理.html">
            
                <a href="docker11 镜像原理.html">
            
                    
                    docker11 镜像原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="docker12 commit镜像.html">
            
                <a href="docker12 commit镜像.html">
            
                    
                    docker12 commit镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="docker13 容器数据卷.html">
            
                <a href="docker13 容器数据卷.html">
            
                    
                    docker13 容器数据卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="docker14 具名挂载和匿名挂载.html">
            
                <a href="docker14 具名挂载和匿名挂载.html">
            
                    
                    docker14 具名挂载和匿名挂载
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.16" data-path="docker15 初始dockerfile.html">
            
                <a href="docker15 初始dockerfile.html">
            
                    
                    docker15 初始dockerfile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="docker16 数据卷容器.html">
            
                <a href="docker16 数据卷容器.html">
            
                    
                    docker16 数据卷容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="docker17 dockerFile.html">
            
                <a href="docker17 dockerFile.html">
            
                    
                    docker17 dockerFile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="docker18 dockerFile基本命令.html">
            
                <a href="docker18 dockerFile基本命令.html">
            
                    
                    docker18 dockerFile基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="docker19 构建自己的centos.html">
            
                <a href="docker19 构建自己的centos.html">
            
                    
                    docker19 构建自己的centos
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="docker20 发布镜像.html">
            
                <a href="docker20 发布镜像.html">
            
                    
                    docker20 发布镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="docker21 网络详情.html">
            
                <a href="docker21 网络详情.html">
            
                    
                    docker21 网络详情
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="docker22 容器互联.html">
            
                <a href="docker22 容器互联.html">
            
                    
                    docker22 容器互联
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="docker23 自定义网络.html">
            
                <a href="docker23 自定义网络.html">
            
                    
                    docker23 自定义网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                <a href="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                    
                    docker24 SpringBoot 微服务打包Docker镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="docker25 dockerFile_demo.html">
            
                <a href="docker25 dockerFile_demo.html">
            
                    
                    docker25 dockerFile_demo
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >docker15 初始dockerfile</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x521D;&#x59CB;dockerfile">&#x521D;&#x59CB;dockerfile</h3>
<blockquote>
<p>&#x65B9;&#x5F0F;&#x4E8C;</p>
</blockquote>
<p><strong>dockerfile &#x5C31;&#x662F;&#x7528;&#x6765;&#x6784;&#x5EFA;docker&#x955C;&#x50CF;&#x7684;&#x6784;&#x5EFA;&#x6587;&#x4EF6;!&#x547D;&#x4EE4;&#x811A;&#x672C;! &#x5148;&#x4F53;&#x9A8C;&#x4E00;&#x4E0B;!</strong></p>
<ul>
<li>&#x901A;&#x8FC7;&#x8FD9;&#x811A;&#x672C;&#x53EF;&#x4EE5;&#x751F;&#x6210;&#x4E00;&#x4E2A;&#x955C;&#x50CF;,&#x955C;&#x50CF;&#x662F;&#x4E00;&#x5C42;&#x4E00;&#x5C42;&#x7684;,&#x811A;&#x672C;&#x662F;&#x4E00;&#x4E2A;&#x4E2A;&#x547D;&#x4EE4;,&#x6BCF;&#x4E2A;&#x547D;&#x4EE4;&#x90FD;&#x662F;&#x4E00;&#x5C42;</li>
<li>&#x521B;&#x5EFA;&#x4E00;&#x4E2A;dockerfile&#x6587;&#x4EF6;,&#x540D;&#x5B57;&#x53EF;&#x4EE5;&#x968F;&#x673A; &#x5EFA;&#x8BAE;dockerfile</li>
<li>&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x5185;&#x5BB9;&#x6307;&#x4EE4;(&#x5927;&#x5199;) &#x53C2;&#x6570;</li>
</ul>
<pre><code class="lang-bash">FROM centos

VOLUME [<span class="hljs-string">&quot;volume01&quot;</span>,<span class="hljs-string">&quot;volume02&quot;</span>]

CMD <span class="hljs-built_in">echo</span> <span class="hljs-string">&quot;------end------&quot;</span>

CMD /bin/bash/
</code></pre>
<p><strong>&#x8FD9;&#x91CC;&#x7684;&#x6BCF;&#x4E00;&#x4E2A;&#x547D;&#x4EE4;&#x90FD;&#x662F;&#x955C;&#x50CF;&#x7684;&#x4E00;&#x5C42;</strong></p>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x6D4B;&#x8BD5;&#x4E00;&#x4E0B;</span>
[root@izijy66dzll7bdz testdockerfile]<span class="hljs-comment"># docker build -f /home/testdockerfile/dockerfile1  -t yangxin/centos:1.0 .</span>
Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM centos
 ---&gt; 300e315adb2f
Step 2/4 : VOLUME [<span class="hljs-string">&quot;volume01&quot;</span>,<span class="hljs-string">&quot;volume02&quot;</span>]
 ---&gt; Running <span class="hljs-keyword">in</span> afc4fa2238a5
Removing intermediate container afc4fa2238a5
 ---&gt; 01bfa5ed71ee
Step 3/4 : CMD <span class="hljs-built_in">echo</span> <span class="hljs-string">&quot;------end------&quot;</span>
 ---&gt; Running <span class="hljs-keyword">in</span> 7ad75c036184
Removing intermediate container 7ad75c036184
 ---&gt; f38bea066e84
Step 4/4 : CMD /bin/bash/
 ---&gt; Running <span class="hljs-keyword">in</span> c1cfa13fe151
Removing intermediate container c1cfa13fe151
 ---&gt; f075536ec0f3
Successfully built f075536ec0f3
Successfully tagged yangxin/centos:1.0
[root@izijy66dzll7bdz testdockerfile]<span class="hljs-comment">#</span>
</code></pre>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x542F;&#x52A8;&#x4E00;&#x4E0B;&#x81EA;&#x5DF1;&#x7684;&#x955C;&#x50CF;</span>
[root@izijy66dzll7bdz testdockerfile]<span class="hljs-comment"># docker run -it yangxin/centos:1.0 /bin/bash</span>
[root@7e6275b8e021 /]<span class="hljs-comment"># ls</span>
bin  etc   lib    lost+found  mnt  proc  run   srv  tmp  var       volume02
dev  home  lib64  media       opt  root  sbin  sys  usr  volume01
[root@7e6275b8e021 /]<span class="hljs-comment"># cd volume01</span>
[root@7e6275b8e021 volume01]<span class="hljs-comment"># ls</span>
</code></pre>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210323193127.png" alt=""></p>
<p><strong>&#x4E0A;&#x9762;&#x7684;volume01&#x548C;volume02&#x5C31;&#x662F;&#x6211;&#x4EEC;&#x81EA;&#x5DF1;&#x6302;&#x8F7D;&#x7684;,&#x8FD9;&#x4E2A;&#x5377;&#x548C;&#x5916;&#x90E8;&#x4E00;&#x5B9A;&#x662F;&#x6709;&#x4E00;&#x4E2A;&#x540C;&#x6B65;&#x7684;</strong></p>
<p>&#x6D4B;&#x8BD5;&#x4E00;&#x4E0B;&#x521A;&#x624D;&#x7684;&#x6587;&#x4EF6;&#x662F;&#x5426;&#x540C;&#x6B65;&#x51FA;&#x53BB;&#x4E86;</p>
<pre><code class="lang-bash">[root@izijy66dzll7bdz _data]<span class="hljs-comment"># cd /var/lib/docker/volumes/7a6550091a32f65730341e7d72c295e5b7c5ef2bc48cbd9486047a8c1fc88f92/_data</span>
[root@izijy66dzll7bdz _data]<span class="hljs-comment"># ls</span>
contairner.txt
[root@izijy66dzll7bdz _data]<span class="hljs-comment">#</span>
</code></pre>
<p>&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x6211;&#x4EEC;&#x672A;&#x6765;&#x4F7F;&#x7528;&#x7684;&#x5341;&#x5206;&#x591A;,&#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x901A;&#x5E38;&#x4F1A;&#x6784;&#x5EFA;&#x81EA;&#x5DF1;&#x7684;&#x955C;&#x50CF;</p>
<p>&#x5047;&#x8BBE;&#x6784;&#x5EFA;&#x955C;&#x50CF;&#x7684;&#x65F6;&#x5019;&#x6CA1;&#x6709;&#x6302;&#x8F7D;&#x5377;,&#x8981;&#x624B;&#x52A8;&#x955C;&#x50CF;&#x6302;&#x8F7D; -v &#x5377;&#x540D;:&#x5BB9;&#x5668;&#x5185;&#x8DEF;&#x5F84;!</p>
<p>&#x5BB9;&#x5668;&#x95F4;&#x4E5F;&#x53EF;&#x4EE5;&#x6570;&#x636E;&#x5171;&#x4EAB;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="docker14 具名挂载和匿名挂载.html" class="navigation navigation-prev " aria-label="Previous page: docker14 具名挂载和匿名挂载">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="docker16 数据卷容器.html" class="navigation navigation-next " aria-label="Next page: docker16 数据卷容器">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"docker15 初始dockerfile","level":"1.16","depth":1,"next":{"title":"docker16 数据卷容器","level":"1.17","depth":1,"path":"docker16 数据卷容器.md","ref":"docker16 数据卷容器.md","articles":[]},"previous":{"title":"docker14 具名挂载和匿名挂载","level":"1.15","depth":1,"path":"docker14 具名挂载和匿名挂载.md","ref":"docker14 具名挂载和匿名挂载.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"docker15 初始dockerfile.md","mtime":"2021-04-17T06:21:12.835Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-04-17T07:50:48.567Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

